
//
// 120524 - AH - (Aura) Created.
//

package org.soekrat.server.io.db;

/**
 * <p>
 *   Represents a semantic effect.  
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
public final class SemanticEffect extends ParameterBase
{
  private long ownerId;
  
  private String name;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public SemanticEffect(){}
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param ownerId Owner's key.
   * @throws IllegalArgumentException If {@code owner<0}.
   */
  public SemanticEffect(long ownerId)
  {
    if (ownerId<0)
    {
      throw new IllegalArgumentException("ownerId<0 : "+ownerId);
    }
    
    this.ownerId=ownerId;
  }
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param name    Name of {@code this} semantic effects.
   * @param ownerId Owner's key. 
   * @throws IllegalArgumentException If {@code owner<0}. 
   */
  public SemanticEffect(String name, long ownerId)
  { 
    this(ownerId); setName(name); 
  }
  
  /**
   * <p>
   *   Sets name on {@code this} semantic effect.
   * </p>
   * @return Name.
   */
  public SemanticEffect setName(String name)
  {
    if (name==null)
    {
      throw new NullPointerException("name");
    }
    
    this.name=name;
    return this;
  }
  
  /**
   * <p>
   *   Gets key for {@code this} owner.
   * </p>
   * @return Key.
   */
  public long getOwner(){ return this.ownerId; }
  
  /**
   * <p>
   *   Gets name on {@code this} semantic effect.
   * </p>
   * @return Name.
   */
  public String getName(){ return name; }
  
  @Override
  public String toString() 
  {
    StringBuilder sb=new StringBuilder();
    sb.append("id=").append(id()).append(", ownerId=").append(ownerId)
      .append(", name=").append(name).append(", ").append(super.toString());
    return sb.toString();
  }
  
}
